<?php
namespace app\api\controller;

use app\api\model\PictureModel;
use think\Controller;
class Picture extends Controller
{
function picturelist() {
        $model = new pictureModel();
        $result = $model->picturelist();
        return json_encode($result);
    }
     function picturedetail() {
        $pictureid = input('get.pictureid');
        $model = new PictureModel();
        $result = $model->picturedetail($pictureid);
        return json_encode($result);
    }
    function reply() {
        $userid = input('get.userid');
        $pictureid =input('get.pictureid');
        $content =input('get.content');
        $sessionid = input('get.sessionid');

        $redis = getRedis();
        if ($sessionid!='' && $sessionid == $redis->get($userid)) {
            $model = new PictureModel();
            $result = $model->reply($userid,$pictureid,$content);
            return json($result);
        }
        return  json(['error'=>'sessionid无效']);
    }
}